package com.cn.modules.menu;
import java.util.List;
import com.cn.common.utils.Message;
import com.cn.component.TreeUtils;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;

public class MenuController extends Controller {

	public void index() {
		Page<Menu> page = Menu.dao.selectJqGridPage(getParaToInt("page"), getParaToInt("rows"),getPara("sidx"), getPara("sord"));
		renderJson(page);
	}

	public void save() {
		renderJson(new Message(getModel(Menu.class).save(), ""));
	}

	public void update() {
		renderJson(new Message(getModel(Menu.class).update(), ""));
	}

	public void getMenu() {
		renderJson(new Message(true, "",Menu.dao.findById(getPara("CODE"))));

	}

	public void findMenu() {
		List<Menu> mList = Menu.dao.findMenuyParentId(getPara("PARENT_ID", "001"));
		renderJson(mList);
	}

	public void getTree() {
		renderJson(TreeUtils.getTreeNode(Menu.dao.getTreeNodeList()));
	}
}
